// 1.引入封装好的axios
import axios from '@/utils/myaxios.js'

// 获取所有用户数据
export const getAllUsers = (params) => {
  return axios({
    url: 'users',
    params
  })
}

// 实现用户的新增
export const addUsers = (data) => {
  return axios({
    url: 'users',
    method: 'post',
    data
  })
}

// 实现编辑用户操作
export const editUsers = (data) => {
  return axios({
    url: `users/${data.id}`,
    method: 'put',
    data
  })
}

// 实现用户角色分配
export const userRole = (data) => {
  return axios({
    url: `users/${data.id}/role`,
    method: 'put',
    data
  })
}

// 实现删除用户
export const delUserById = (id) => {
  return axios({
    url: `users/${id}`,
    method: 'delete',
    id
  })
}

// 实现用户状态的修改
export const userStatusChange = (uId, type) => {
  return axios({
    url: `users/${uId}/state/${type}`,
    method: 'put'
  })
}
